﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Provides functionality of a list control.
	/// </summary>
	public interface IListControl
	{
		/// <summary>
		/// List of top-level items in this list control (options and/or groups).
		/// </summary>
		ListItemCollection Items { get; }
		/// <summary>
		/// Gets all options in this list control (no groups).
		/// </summary>
		ListItem[] Options { get; }
		/// <summary>
		/// The CSS class applied to all items which don't have a class individually specified for them.
		/// </summary>
		string ItemCssClass { get; set; }
		/// <summary>
		/// The CSS class applied to all groups which don't have a class individually specified for them.
		/// </summary>
		string GroupCssClass { get; set; }
		/// <summary>
		/// The items which are automatically inserted at the top of list when performing DataBind. If this is empty, no items will be inserted. Used for stuff like "Select a country" etc.
		/// </summary>
		List<ListItem> FirstItems { get; }
		/// <summary>
		/// The items which are automatically inserted at the top of each category when performing DataBind. If this is empty, no items will be inserted. Used for stuff like "All in US" under the category "US", etc.
		/// </summary>
		List<ListItem> CategoryFirstItems { get; }
		/// <summary>
		/// Adds the first items to the collection which always precede the data bound items.
		/// </summary>
		void AddFirstItems();
		/// <summary>
		/// Creates the list items by enumerating the specified data source and using the specified value, text and category fields to set properties of the created list items.
		/// </summary>
		/// <param name="dataSource"></param>
		/// <param name="valueField"></param>
		/// <param name="textField"></param>
		/// <param name="categoryField"></param>
		void DataBind(object dataSource, string valueField, string textField, string categoryField);
		/// <summary>
		/// Renders the specified group item to HTML output.
		/// </summary>
		/// <param name="writer"></param>
		/// <param name="item"></param>
		void RenderItemGroup(System.Web.UI.HtmlTextWriter writer, ListItem item);
		/// <summary>
		/// Renders the specified option item to HTML output.
		/// </summary>
		/// <param name="writer"></param>
		/// <param name="item"></param>
		void RenderItemOption(System.Web.UI.HtmlTextWriter writer, ListItem item);
	}
}
